home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / librw / RWvistream.z / RWvistream
Encoding:
Text File  |  1998-10-30  |  17.0 KB  |  397 lines

  1.  
  2.  
  3.  
  4. RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                              RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  5.  
  6.  
  7.  
  8. NNNNaaaammmmeeee
  9.      RWvistream - Rogue Wave library class
  10.  
  11. SSSSyyyynnnnooooppppssssiiiissss
  12.               #include <rw/vstream.h>
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20. DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn
  21.      Class RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm is an abstract base class.  It provides an interface for
  22.      format-independent retrieval of fundamental types and arrays of
  23.      fundamental types.  Its counterpart, RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm, provides a complementary
  24.      interface for the storage of the fundamental types. Because the interface
  25.      of RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm and RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm is independent of formatting, the user of
  26.      these classes need not be concerned with how variables will actually be
  27.      stored or restored.  That will be up to the derived class to decide.  It
  28.      might be done using an operating-system independent ASCII format (classes
  29.      RRRRWWWWppppiiiissssttttrrrreeeeaaaammmm and RRRRWWWWppppoooossssttttrrrreeeeaaaammmm), a binary format (classes RRRRWWWWbbbbiiiissssttttrrrreeeeaaaammmm and
  30.      RRRRWWWWbbbboooossssttttrrrreeeeaaaammmm), or the user could define his or her own format (eeee....gggg...., an
  31.      interface to a network).  Note that because it is an aaaabbbbssssttttrrrraaaacccctttt base class,
  32.      there is no way to actually enforce these goals -- the description here
  33.      is merely the model of how a class derived from RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm and RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm
  34.      should act.  See class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm for additional explanations and
  35.      examples of format-independent stream storage.
  36.  
  37. PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee
  38.      None
  39.  
  40. EEEExxxxaaaammmmpppplllleeee
  41.               #include <rw/vstream.h>
  42.           void restoreStuff( RWvistream& str) {
  43.              int i;
  44.              double d;
  45.              char string[80];
  46.              str >> i;  // Restore an int
  47.              str >> d;  // Restore a double
  48.              // Restore a character string, up to 80 characters long:
  49.              str.getString(string, sizeof(string));
  50.              if(str.fail()) cerr << "Oh, oh, bad news.0;
  51.  
  52. PPPPuuuubbbblllliiiicccc DDDDeeeessssttttrrrruuuuccccttttoooorrrr
  53.      }
  54.  
  55.  
  56.  
  57.               virtual ~~~~RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm();
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                              RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.      This virtual destructor allows specializing classes to deallocate any
  78.      resources that they may have allocated.
  79.  
  80. PPPPuuuubbbblllliiiicccc OOOOppppeeeerrrraaaattttoooorrrrssss
  81.               virtual RWvistream&
  82.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(char& c) = 0;
  83.  
  84.  
  85.      Get the next cccchhhhaaaarrrr from the input stream and store it in cccc.
  86.  
  87.               virtual RWvistream&
  88.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(wchar_t& wc) = 0;
  89.  
  90.  
  91.      Get the next wwwwcccchhhhaaaarrrr____tttt from the input stream and store it in wwwwcccc.
  92.  
  93.               virtual RWvistream&
  94.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(double& d) = 0;
  95.  
  96.  
  97.      Get the next ddddoooouuuubbbblllleeee from the input stream and store it in dddd.
  98.  
  99.               virtual RWvistream&
  100.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(float& f) = 0;
  101.  
  102.  
  103.      Get the next ffffllllooooaaaatttt from the input stream and store it in ffff.
  104.  
  105.               virtual RWvistream&
  106.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(int& i) = 0;
  107.  
  108.  
  109.      Get the next iiiinnnntttt from the input stream and store it in iiii.
  110.  
  111.               virtual RWvistream&
  112.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(long& l) = 0;
  113.  
  114.  
  115.      Get the next lllloooonnnngggg from the input stream and store it in llll.
  116.  
  117.               virtual RWvistream&
  118.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(short& s) = 0;
  119.  
  120.  
  121.      Get the next sssshhhhoooorrrrtttt from the input stream and store it in ssss.
  122.  
  123.               virtual RWvistream&
  124.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(unsigned char& c) = 0;
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                              RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  137.  
  138.  
  139.  
  140.      Get the next uuuunnnnssssiiiiggggnnnneeeedddd cccchhhhaaaarrrr from the input stream and store it in cccc.
  141.  
  142.               virtual RWvistream&
  143.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(unsigned short& s) = 0;
  144.  
  145.  
  146.      Get the next uuuunnnnssssiiiiggggnnnneeeedddd sssshhhhoooorrrrtttt from the input stream and store it in ssss.
  147.  
  148.               virtual RWvistream&
  149.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(unsigned int& i) = 0;
  150.  
  151.  
  152.      Get the next uuuunnnnssssiiiiggggnnnneeeedddd iiiinnnntttt from the input stream and store it in iiii.
  153.  
  154.               virtual RWvistream&
  155.           ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(unsigned long& l) = 0;
  156.  
  157.  
  158.      Get the next uuuunnnnssssiiiiggggnnnneeeedddd lllloooonnnngggg from the input stream and store it in llll.
  159.  
  160.               ooooppppeeeerrrraaaattttoooorrrr vvvvooooiiiidddd****();
  161.  
  162.  
  163.      Inherited from RRRRWWWWvvvviiiioooossss.
  164.  
  165. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss
  166.               virtual int
  167.           ggggeeeetttt() = 0;
  168.  
  169.  
  170.      Get and return the next byte from the input stream, returning its value.
  171.      Returns EEEEOOOOFFFF if end of file is encountered.
  172.  
  173.               virtual RWvistream&
  174.           ggggeeeetttt(char& c) = 0;
  175.  
  176.  
  177.      Get the next cccchhhhaaaarrrr from the input stream, returning its value in cccc.
  178.  
  179.               virtual RWvistream&
  180.           ggggeeeetttt(wchar_t& wc) = 0;
  181.  
  182.  
  183.      Get the next wwwwcccchhhhaaaarrrr____tttt from the input stream, returning its value in wwwwcccc.
  184.  
  185.               virtual RWvistream&
  186.           ggggeeeetttt(unsigned char& c) = 0;
  187.  
  188.  
  189.      Get the next uuuunnnnssssiiiiggggnnnneeeedddd cccchhhhaaaarrrr from the input stream, returning its value in
  190.      cccc.
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                              RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  203.  
  204.  
  205.  
  206.               virtual RWvistream&
  207.           ggggeeeetttt(char* v, size_t N) = 0;
  208.  
  209.  
  210.      Get a vector of cccchhhhaaaarrrrs and store them in the array beginning at vvvv. If the
  211.      restore operation stops prematurely because there are no more data
  212.      available on the stream, because an exception is thrown, or for some
  213.      other reason, ggggeeeetttt stores what has already been retrieved from the stream
  214.      into vvvv, and sets the failbit. Note that ggggeeeetttt retrieves raw characters and
  215.      does not perform any conversions on speical characters such as "0.
  216.  
  217.               virtual RWvistream&
  218.           ggggeeeetttt(wchar_t* v, size_t N) = 0;
  219.  
  220.  
  221.      Get a vector of wide characterss and store them in the array beginning at
  222.      vvvv. If the restore operation stops prematurely because there are no more
  223.      data available on the stream, because an exception is thrown, or for some
  224.      other reason, ggggeeeetttt stores what has already been retrieved from the stream
  225.      into vvvv, and sets the failbit. Note that ggggeeeetttt retrieves raw characters and
  226.      does not perform any conversions on speical characters such as "0.
  227.  
  228.               virtual RWvistream&
  229.           ggggeeeetttt(double* v, size_t N) = 0;
  230.  
  231.  
  232.      Get a vector of NNNN ddddoooouuuubbbblllleeees and store them in the array beginning at vvvv. If
  233.      the restore operation stops prematurely because there are no more data
  234.      available on the stream, because an exception is thrown, or for some
  235.      other reason, ggggeeeetttt stores what has already been retrieved from the stream
  236.      into vvvv, and sets the failbit.
  237.  
  238.               virtual RWvistream&
  239.           ggggeeeetttt(float* v, size_t N) = 0;
  240.  
  241.  
  242.      Get a vector of NNNN ffffllllooooaaaatttts and store them in the array beginning at vvvv. If
  243.      the restore operation stops prematurely because there are no more data
  244.      available on the stream, because an exception is thrown, or for some
  245.      other reason, ggggeeeetttt stores what has already been retrieved from the stream
  246.      into vvvv, and sets the failbit.
  247.  
  248.               virtual RWvistream&
  249.           ggggeeeetttt(int* v, size_t N) = 0;
  250.  
  251.  
  252.      Get a vector of NNNN iiiinnnntttts and store them in the array beginning at vvvv. If the
  253.      restore operation stops prematurely because there are no more data
  254.      available on the stream, because an exception is thrown, or for some
  255.      other reason, ggggeeeetttt stores what has already been retrieved from the stream
  256.      into vvvv, and sets the failbit.
  257.  
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                              RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  269.  
  270.  
  271.  
  272.               virtual RWvistream&
  273.           ggggeeeetttt(long* v, size_t N) = 0;
  274.  
  275.  
  276.      Get a vector of NNNN lllloooonnnnggggs and store them in the array beginning at vvvv. If
  277.      the restore operation stops prematurely because there are no more data
  278.      available on the stream, because an exception is thrown, or for some
  279.      other reason,ggggeeeetttt stores what has already been retrieved from the stream
  280.      into vvvv, and sets the failbit.
  281.  
  282.               virtual RWvistream&
  283.           ggggeeeetttt(short* v, size_t N) = 0;
  284.  
  285.  
  286.      Get a vector of NNNN sssshhhhoooorrrrtttts and store them in the array beginning at vvvv. If
  287.      the restore operation stops prematurely because there are no more data
  288.      available on the stream, because an exception is thrown, or for some
  289.      other reason,ggggeeeetttt stores what has already been retrieved from the stream
  290.      into vvvv, and sets the failbit.
  291.  
  292.               virtual RWvistream&
  293.           ggggeeeetttt(unsigned char* v, size_t N) = 0;
  294.  
  295.  
  296.      Get a vector of NNNN uuuunnnnssssiiiiggggnnnneeeedddd cccchhhhaaaarrrrs and store them in the array beginning at
  297.      vvvv. If the restore operation stops prematurely because there are no more
  298.      data available on the stream, because an exception is thrown, or for some
  299.      other reason, ggggeeeetttt stores what has already been retrieved from the stream
  300.      into vvvv, and sets the failbit. Note that this member preserves ASCII
  301.      numerical codes, not their corresponding character values.  If you wish
  302.      to restore a character string, use the function ggggeeeettttSSSSttttrrrriiiinnnngggg((((cccchhhhaaaarrrr****,,,, ssssiiiizzzzeeee____tttt))))....
  303.  
  304.               virtual RWvistream&
  305.           ggggeeeetttt(unsigned short* v, size_t N) = 0;
  306.  
  307.  
  308.      Get a vector of NNNN uuuunnnnssssiiiiggggnnnneeeedddd sssshhhhoooorrrrtttts and store them in the array beginning
  309.      at vvvv. If the restore operation stops prematurely because there are no
  310.      more data available on the stream, because an exception is thrown, or for
  311.      some other reason, ggggeeeetttt stores what has already been retrieved from the
  312.      stream into vvvv, and sets the failbit.
  313.  
  314.               virtual RWvistream&
  315.           ggggeeeetttt(unsigned int* v, size_t N) = 0;
  316.  
  317.  
  318.      Get a vector of NNNN uuuunnnnssssiiiiggggnnnneeeedddd iiiinnnntttts and store them in the array beginning at
  319.      vvvv. If the restore operation stops prematurely because there are no more
  320.      data available on the stream, because an exception is thrown, or for some
  321.      other reason, ggggeeeetttt stores what has already been retrieved from the stream
  322.      into vvvv, and sets the failbit.
  323.  
  324.  
  325.  
  326.  
  327.                                                                         PPPPaaaaggggeeee 5555
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                              RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  335.  
  336.  
  337.  
  338.               virtual RWvistream&
  339.           ggggeeeetttt(unsigned long* v, size_t N) = 0;
  340.  
  341.  
  342.      Get a vector of NNNN uuuunnnnssssiiiiggggnnnneeeedddd lllloooonnnnggggs and store them in the array beginning at
  343.      vvvv. If the restore operation stops prematurely because there are no more
  344.      data available on the stream, because an exception is thrown, or for some
  345.      other reason, ggggeeeetttt stores what has already been retrieved from the stream
  346.      into vvvv, and sets the failbit.
  347.  
  348.               virtual RWvistream&
  349.           ggggeeeettttSSSSttttrrrriiiinnnngggg(char* s, size_t N) = 0;
  350.  
  351.  
  352.      Restores a character string from the input stream that was stored to the
  353.      output stream with RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm::::::::ppppuuuuttttssssttttrrrriiiinnnngggg and stores it in the array
  354.      beginning at ssss. The function stops reading at the end of the string or
  355.      after NNNN----1111 characters, whichever comes first.  If NNNN----1111 characters have been
  356.      read and the NNNNtttthhhh character is not the string terminator, then the failbit
  357.      of the stream will be set.  In either case, the string will be terminated
  358.      with a null byte.
  359.  
  360.               virtual RWvistream&
  361.           ggggeeeettttSSSSttttrrrriiiinnnngggg(wchar_t* ws, size_t N) = 0;
  362.  
  363.  
  364.      Restores a wide character string from the input stream that was stored to
  365.      the output stream with RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm::::::::ppppuuuuttttssssttttrrrriiiinnnngggg and stores it in the array
  366.      beginning at wwwwssss. The function stops reading at the end of the string or
  367.      after NNNN----1111 characters, whichever comes first.  If NNNN----1111 characters have been
  368.      read and the NNNNtttthhhh character is not the string terminator, then the failbit
  369.      of the stream will be set.  In either case, the string will be terminated
  370.      with a null byte.
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.                                                                         PPPPaaaaggggeeee 6666
  394.  
  395.  
  396.  
  397.